package com.tangcco.lockwell.controller.common;

import com.tangcco.lockwell.base.RestResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

/**
 * @author yanxinping
 * @date 2021/10/26 16:22
 * 首页配置类
 */
@RestController
@RequestMapping("/api/home")
public class HomePageController {
    @Value("${common.kaoyanTime}")
    private String kaoyanTime;

    @RequestMapping(value = "/stillTime", method = RequestMethod.GET)
    public RestResponse<Long> stillTime(){
        LocalDate today = LocalDate.now();

        LocalDate java8Release = LocalDate.parse(kaoyanTime);

        long daysBetween = ChronoUnit.DAYS.between(today, java8Release);
        return RestResponse.ok(daysBetween);
    }
}
